package ru.pb.game.handlers;

import gnu.trove.map.hash.TIntObjectHashMap;
import ru.pb.game.handlers.interfaces.IChatHandler;
import ru.pb.game.objects.model.chat.CHATTING_TYPE;
import ru.pb.global.xml.holder.AbstractHolder;

/**
 * @author Felixx
 */
public class ChatHandler extends AbstractHolder
{
	private static ChatHandler _instance;
	private TIntObjectHashMap<IChatHandler> _list = new TIntObjectHashMap<IChatHandler>(CHATTING_TYPE.values().length);

	public static ChatHandler getInstance()
	{
		if(_instance == null)
		{
			_instance = new ChatHandler();
		}
		return _instance;
	}

	private ChatHandler()
	{}

	public void register(IChatHandler handler)
	{
		_list.put(handler.getChatType().getId(), handler);
	}

	public IChatHandler get(int id)
	{
		return _list.get(id);
	}

	@Override
	public int size()
	{
		return _list.size();
	}

	@Override
	public void clear()
	{
		_list.clear();
	}
}